# Copyright 2024-2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

package(
    default_visibility = ["//visibility:public"],
)

cc_library(
    name = "color",
    srcs = ["color.cc"],
    hdrs = [
        "color.h",
        "color_helpers.h",
    ],
    deps = [
        ":color_space",
        "@com_google_absl//absl/log:absl_check",
        "@com_google_absl//absl/log:absl_log",
        "@com_google_absl//absl/strings:str_format",
    ],
)

cc_test(
    name = "color_test",
    srcs = ["color_test.cc"],
    shard_count = 10,
    deps = [
        ":color",
        ":color_space",
        ":fuzz_domains",
        ":type_matchers",
        "@com_google_absl//absl/hash:hash_testing",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
    ],
)

cc_test(
    name = "color_helpers_test",
    srcs = ["color_helpers_test.cc"],
    deps = [
        ":color",
        ":type_matchers",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
    ],
)

cc_library(
    name = "color_space",
    srcs = ["color_space.cc"],
    hdrs = ["color_space.h"],
    deps = [
        "@com_google_absl//absl/log:absl_log",
        "@com_google_absl//absl/strings:str_format",
    ],
)

cc_test(
    name = "color_space_test",
    srcs = ["color_space_test.cc"],
    shard_count = 10,
    deps = [
        ":color_space",
        ":fuzz_domains",
        ":type_matchers",
        "@com_google_absl//absl/strings",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
    ],
)

cc_library(
    name = "fuzz_domains",
    testonly = 1,
    srcs = ["fuzz_domains.cc"],
    hdrs = ["fuzz_domains.h"],
    deps = [
        ":color",
        ":color_space",
        "@com_google_fuzztest//fuzztest",
    ],
)

cc_library(
    name = "type_matchers",
    testonly = 1,
    srcs = ["type_matchers.cc"],
    hdrs = ["type_matchers.h"],
    deps = [
        ":color",
        "//:gtest_for_library_testonly",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
    ],
)
